﻿using System;
using Character;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

// Token: 0x020001DA RID: 474
public class CharaColorCopyHelper : MonoBehaviour
{
	// Token: 0x06000CA5 RID: 3237 RVA: 0x0004B948 File Offset: 0x00049B48
	public void Setup(Human human)
	{
		this.human = human;
		this.tabs[1].gameObject.SetActive(human.sex == SEX.FEMALE);
		for (int i = 0; i < this.fromToggles.Length; i++)
		{
			this.fromToggles[i].onValueChanged.AddListener(new UnityAction<bool>(this.OnCheckTab));
		}
		for (int j = 0; j < this.toToggles.Length; j++)
		{
			this.toToggles[j].onValueChanged.AddListener(new UnityAction<bool>(this.OnCheck));
		}
		for (int k = 0; k < this.tabs.Length; k++)
		{
			this.tabs[k].onValueChanged.AddListener(new UnityAction<bool>(this.OnCheckTab));
		}
	}

	// Token: 0x06000CA6 RID: 3238 RVA: 0x0004BA1C File Offset: 0x00049C1C
	private void Update()
	{
		this.playSE = false;
		int num = -1;
		for (int i = 0; i < this.tabs.Length; i++)
		{
			if (this.tabs[i].isOn)
			{
				num = i;
				break;
			}
		}
		if (num != this.tab)
		{
			this.ChangeTab(num);
		}
		for (int j = 0; j < this.fromToggles.Length; j++)
		{
			if (this.fromToggles[j].isOn)
			{
				this.from = j;
				break;
			}
		}
		for (int k = 0; k < this.toToggles.Length; k++)
		{
			this.toToggles[k].gameObject.SetActive(k != this.from);
		}
		this.playSE = true;
	}

	// Token: 0x06000CA7 RID: 3239 RVA: 0x0004BAEC File Offset: 0x00049CEC
	private void ChangeTab(int newTab)
	{
		bool flag = this.playSE;
		this.playSE = false;
		this.tab = newTab;
		string[,] array = (this.human.sex != SEX.FEMALE) ? CharaColorCopyHelper.NamesM : CharaColorCopyHelper.NamesF;
		for (int i = 0; i < this.fromToggles.Length; i++)
		{
			this.fromToggles[i].GetComponentInChildren<Text>().text = array[this.tab, i];
		}
		this.fromToggles[0].isOn = true;
		for (int j = 0; j < this.toToggles.Length; j++)
		{
			this.toToggles[j].GetComponentInChildren<Text>().text = array[this.tab, j];
			this.toToggles[j].isOn = false;
		}
		this.playSE = flag;
	}

	// Token: 0x06000CA8 RID: 3240 RVA: 0x0004BBC4 File Offset: 0x00049DC4
	public void Button_Copy()
	{
		if (this.tab == 0)
		{
			for (int i = 0; i < this.toToggles.Length; i++)
			{
				if (this.toToggles[i].gameObject.activeSelf && this.toToggles[i].isOn)
				{
					this.Copy_Hair(i);
				}
			}
		}
		else if (this.tab == 1)
		{
			for (int j = 0; j < this.toToggles.Length; j++)
			{
				if (this.toToggles[j].gameObject.activeSelf && this.toToggles[j].isOn)
				{
					this.Copy_Skin(j);
				}
			}
		}
		if (this.playSE)
		{
			SystemSE.Play(SystemSE.SE.YES);
		}
	}

	// Token: 0x06000CA9 RID: 3241 RVA: 0x0004BC90 File Offset: 0x00049E90
	private void OnCheck(bool check)
	{
		SystemSE.SE se = (!check) ? SystemSE.SE.NO : SystemSE.SE.YES;
		if (this.playSE)
		{
			SystemSE.Play(se);
		}
	}

	// Token: 0x06000CAA RID: 3242 RVA: 0x0004BCBC File Offset: 0x00049EBC
	private void OnCheckTab(bool check)
	{
		if (this.playSE && check)
		{
			SystemSE.Play(SystemSE.SE.CHOICE);
		}
	}

	// Token: 0x06000CAB RID: 3243 RVA: 0x0004BCD8 File Offset: 0x00049ED8
	private void Copy_Hair(int to)
	{
		Color color = Color.white;
		if (this.from == 0)
		{
			color = this.human.customParam.hair.parts[0].hairColor.mainColor;
		}
		else if (this.from == 1)
		{
			color = this.human.customParam.head.eyeBrowColor.mainColor1;
		}
		else if (this.from == 2)
		{
			if (this.human.sex == SEX.FEMALE)
			{
				color = this.human.customParam.head.eyeLashColor.mainColor1;
			}
			else
			{
				color = this.human.customParam.head.beardColor;
			}
		}
		else if (this.from == 3)
		{
			color = this.human.customParam.body.underhairColor.mainColor;
		}
		if (to == 0)
		{
			for (int i = 0; i < this.human.customParam.hair.parts.Length; i++)
			{
				this.human.customParam.hair.parts[i].hairColor.mainColor = color;
			}
			this.human.hairs.ChangeColor(this.human.customParam.hair);
		}
		else if (to == 1)
		{
			this.human.customParam.head.eyeBrowColor.mainColor1 = color;
			this.human.head.ChangeEyebrowColor();
		}
		else if (to == 2)
		{
			if (this.human.sex == SEX.FEMALE)
			{
				this.human.customParam.head.eyeLashColor.mainColor1 = color;
				this.human.head.ChangeEyelashColor();
			}
			else
			{
				this.human.customParam.head.beardColor = color;
				this.human.head.ChangeBeardColor();
			}
		}
		else if (to == 3)
		{
			this.human.customParam.body.underhairColor.mainColor = color;
			this.human.body.ChangeUnderHairColor();
		}
		this.editMode.ChangedColor();
	}

	// Token: 0x06000CAC RID: 3244 RVA: 0x0004BF24 File Offset: 0x0004A124
	private void Copy_Skin(int to)
	{
		float num = 0f;
		float num2 = 0f;
		float num3 = 0f;
		if (this.from == 0)
		{
			num = this.human.customParam.body.skinColor.offset_h;
			num2 = this.human.customParam.body.skinColor.offset_s;
			num3 = this.human.customParam.body.skinColor.offset_v;
		}
		else if (this.from == 1)
		{
			num = this.human.customParam.body.sunburnColor_H;
			num2 = this.human.customParam.body.sunburnColor_S;
			num3 = this.human.customParam.body.sunburnColor_V;
		}
		else if (this.from == 2)
		{
			num = this.human.customParam.body.nipColor.offset_h;
			num2 = this.human.customParam.body.nipColor.offset_s;
			num3 = this.human.customParam.body.nipColor.offset_v;
		}
		else if (this.from == 3)
		{
			num = this.human.customParam.body.nailColor.offset_h;
			num2 = this.human.customParam.body.nailColor.offset_s;
			num3 = this.human.customParam.body.nailColor.offset_v;
		}
		if (to == 0)
		{
			this.human.customParam.body.skinColor.offset_h = num;
			this.human.customParam.body.skinColor.offset_s = num2;
			this.human.customParam.body.skinColor.offset_v = num3;
			this.ChangeSkin();
		}
		else if (to == 1)
		{
			this.human.customParam.body.sunburnColor_H = num;
			this.human.customParam.body.sunburnColor_S = num2;
			this.human.customParam.body.sunburnColor_V = num3;
			this.ChangeSkin();
		}
		else if (to == 2)
		{
			this.human.customParam.body.nipColor.offset_h = num;
			this.human.customParam.body.nipColor.offset_s = num2;
			this.human.customParam.body.nipColor.offset_v = num3;
			this.human.body.ChangeNipColor();
		}
		else if (to == 3)
		{
			this.human.customParam.body.nailColor.offset_h = num;
			this.human.customParam.body.nailColor.offset_s = num2;
			this.human.customParam.body.nailColor.offset_v = num3;
			this.human.body.ChangeNail();
		}
		this.editMode.ChangedColor();
	}

	// Token: 0x06000CAD RID: 3245 RVA: 0x0004C24C File Offset: 0x0004A44C
	private void ChangeSkin()
	{
		this.human.body.RendSkinTexture();
		this.human.UpdateSkinMaterial();
		this.human.wears.ChangeBodyMaterial(this.human.body.Rend_skin);
		this.human.head.RendSkinTexture();
	}

	// Token: 0x06000CAE RID: 3246 RVA: 0x0004C2A4 File Offset: 0x0004A4A4
	// Note: this type is marked as 'beforefieldinit'.
	static CharaColorCopyHelper()
	{
		string[,] array = new string[2, 4];
		array[0, 0] = "髪";
		array[0, 1] = "眉";
		array[0, 2] = "まつげ";
		array[0, 3] = "陰毛";
		array[1, 0] = "肌";
		array[1, 1] = "日焼け";
		array[1, 2] = "乳首";
		array[1, 3] = "爪";
		CharaColorCopyHelper.NamesF = array;
		string[,] array2 = new string[2, 4];
		array2[0, 0] = "髪";
		array2[0, 1] = "眉";
		array2[0, 2] = "ヒゲ";
		array2[0, 3] = "陰毛";
		array2[1, 0] = "肌";
		array2[1, 1] = "日焼け";
		array2[1, 2] = "乳首";
		array2[1, 3] = "爪";
		CharaColorCopyHelper.NamesM = array2;
	}

	// Token: 0x04000CD0 RID: 3280
	private static readonly string[,] NamesF;

	// Token: 0x04000CD1 RID: 3281
	private static readonly string[,] NamesM;

	// Token: 0x04000CD2 RID: 3282
	public MoveableUI moveable;

	// Token: 0x04000CD3 RID: 3283
	[SerializeField]
	private EditMode editMode;

	// Token: 0x04000CD4 RID: 3284
	[SerializeField]
	private Toggle[] tabs = new Toggle[2];

	// Token: 0x04000CD5 RID: 3285
	[SerializeField]
	private Toggle[] fromToggles = new Toggle[4];

	// Token: 0x04000CD6 RID: 3286
	[SerializeField]
	private Toggle[] toToggles = new Toggle[4];

	// Token: 0x04000CD7 RID: 3287
	private int tab = -1;

	// Token: 0x04000CD8 RID: 3288
	private int from = -1;

	// Token: 0x04000CD9 RID: 3289
	private bool playSE = true;

	// Token: 0x04000CDA RID: 3290
	private Human human;

	// Token: 0x020001DB RID: 475
	private enum TAB
	{
		// Token: 0x04000CDC RID: 3292
		HAIR,
		// Token: 0x04000CDD RID: 3293
		SKIN,
		// Token: 0x04000CDE RID: 3294
		NUM
	}
}
